using IcsSEMCtrl.Com.FieldBus;
using IcsSEMCtrl.Device.Observe;
using IcsSEMCtrl.Event;
using IcsSEMCtrl.Global;
using IcsSEMCtrl.Global.Device;
using IcsSEMCtrl.Service.Logger;
using IcsSEMCtrl.Util.Client;
using System;
using System.Collections.Generic;
namespace IcsSEMCtrl.Device
{
	public abstract class AbstractElement : AbstractUDPElement
	{
		private const string CLASS = "AbstractElement";
		protected Dictionary<string, Observable> observables = new Dictionary<string, Observable>();
		private static Dictionary<string, Observable> global_Observables = new Dictionary<string, Observable>();
		protected string elementId;
		protected ElementType elementType;
		protected string ownerId;
		protected ElementType ownerType;
		protected bool inService = false;
		protected string supplier = null;
		protected string description = null;
		protected ulong cycles;
		public Dictionary<string, Observable> Observables
		{
			get
			{
				return this.observables;
			}
			set
			{
				this.observables = value;
			}
		}
		public static Dictionary<string, Observable> Global_Observables
		{
			get
			{
				return AbstractElement.global_Observables;
			}
			set
			{
				AbstractElement.global_Observables = value;
			}
		}
		public string ElementId
		{
			get
			{
				return this.elementId;
			}
			set
			{
				this.elementId = value;
			}
		}
		public ElementType ElementType
		{
			get
			{
				return this.elementType;
			}
			set
			{
				this.elementType = value;
			}
		}
		public string OwnerId
		{
			get
			{
				return this.ownerId;
			}
			set
			{
				this.ownerId = value;
			}
		}
		public ElementType OwnerType
		{
			get
			{
				return this.ownerType;
			}
			set
			{
				this.ownerType = value;
			}
		}
		public bool InService
		{
			get
			{
				return this.inService;
			}
			set
			{
				this.inService = value;
			}
		}
		public string Supplier
		{
			get
			{
				return this.supplier;
			}
			set
			{
				this.supplier = value;
			}
		}
		public string Description
		{
			get
			{
				return this.description;
			}
			set
			{
				this.description = value;
			}
		}
		public ulong Cycles
		{
			get
			{
				return this.cycles;
			}
			set
			{
				this.cycles = value;
			}
		}
		public AbstractElement()
		{
		}
		public void AddObservable(string observableId, string observablePath, AccessType accessType, DataType dataType, double min, double max, int drivierNo, bool isMonitoring, string connectionInfoString, string description, bool logEnable, string valueInfomation, string remark)
		{
			Observable value = Observable.CreateObservable(this.elementId, this.elementType, observableId, observablePath, accessType, dataType, min, max, drivierNo, isMonitoring, connectionInfoString, description, logEnable, valueInfomation, remark);
			if (!this.observables.ContainsKey(observableId))
			{
				this.observables.Add(observableId, value);
			}
		}
		public void RemoveObservable(string observableId)
		{
			if (this.observables.ContainsKey(observableId))
			{
				Observable observable = this.observables[observableId];
				observable.Delete();
				this.observables.Remove(observableId);
			}
		}
		public Observable GetObservable(string observableId)
		{
			Observable result = null;
			if (this.observables.ContainsKey(observableId))
			{
				result = this.observables[observableId];
			}
			return result;
		}
		public Dictionary<string, Observable> GetObservables()
		{
			return this.Observables;
		}
		public abstract void RegisterObservableToFiledBusDriver(AbstractFieldBusDriver fieldbusDriver);
		protected void PublishEvent(string subject, ECPEvent ecpEvent)
		{
			Naming.GetEventBrokerManager().Publish(subject, ecpEvent);
		}
	}
}
